#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setFixedSize(240,320);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void Widget::on_keypad_0_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_0,Qt::NoModifier,true,false);
    return;
}
void Widget::on_keypad_1_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_1,Qt::NoModifier,true,false);
    return;
}
void Widget::on_keypad_2_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_2,Qt::NoModifier,true,false);
    return;
}
void Widget::on_keypad_3_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_3,Qt::NoModifier,true,false);
    return;
}
void Widget::on_keypad_4_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_4,Qt::NoModifier,true,false);
    return;
}
void Widget::on_keypad_5_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_5,Qt::NoModifier,true,false);
    return;
}
void Widget::on_keypad_6_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_6,Qt::NoModifier,true,false);
    return;
}
void Widget::on_keypad_7_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_7,Qt::NoModifier,true,false);
    return;
}
void Widget::on_keypad_8_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_8,Qt::NoModifier,true,false);
    return;
}
void Widget::on_keypad_9_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_9,Qt::NoModifier,true,false);
    return;
}

void Widget::on_keypad_dot_pressed()
{
    //QWSServer::sendKeyEvent(46,Qt::Key_Period,Qt::NoModifier,true,false);
    return;
}

void Widget::on_keypad_back_pressed()
{
    //QWSServer::sendKeyEvent(-1,Qt::Key_Backspace,Qt::NoModifier,true,false);
    return;
}

void Widget::on_pushButton_2_clicked()
{
    char Readings[256];
    uint32_t numBytes;
    numBytes = 0;

    //vaciaBufferLectura();
    //Solicitar_Variable(varid_Kp_gas);
    write(Puerto_Serie,"YOUR COMMAND STRING HERE",24);

//    numBytes = leerComandoLargo(Readings);
//    qDebug()<< numBytes;
//    for(int i=0;i<256;i++)
//    {
//        printf("%c",Readings[i]);
//    }
//    printf("\n");
}

void Widget::on_pushButton_openport_clicked()
{
    Puerto_Serie = inicializarPuerto("/dev/ttySAC0",B115200);
    qDebug() << "Inicializando puerto: " << Puerto_Serie;
}
